import tcdIO.*;

	class PokerHandProgram {
		public static void main(String[] args) {
		
		Card card1;
		Card card2;
		Card card3;
		Card card4;
		Card card5;
		Hand hand1;
		Terminal terminal1;
		
		terminal1 = new Terminal("Enter your five cards:");
		
		hand1 = new Hand();	//New hand. Totals for all ranks and suits are set to zero
		
	do {
		terminal1.println("Enter your first card:");	//User enters first card:
		card1 = new Card(terminal1.readString ("Rank: "), terminal1.readString ("Suit: "));
		
		terminal1.println("Enter your second card: ");	//User enters second card:
		card2 = new Card(terminal1.readString ("Rank: "), terminal1.readString ("Suit: "));

		terminal1.println("Enter your third card: ");	//User enters third card:
		card3 = new Card(terminal1.readString ("Rank: "), terminal1.readString ("Suit: "));
		
		terminal1.println("Enter your fourth card: ");	//User enters fourth card:
		card4 = new Card(terminal1.readString ("Rank: "), terminal1.readString ("Suit: "));
		
		terminal1.println("Enter your fifth card: ");	//User enters fifth card:
		card5 = new Card(terminal1.readString ("Rank: "), terminal1.readString ("Suit: "));
		
		hand1.set(card1);	//Cards are transferred into hand class, where the total of the ranks and suits are stored
		hand1.set(card2);
		hand1.set(card3);
		hand1.set(card4);
		hand1.set(card5);
		
		
			//Methods are used to ensure that 5 ranks and 5 suits have been stored, and that no same card was entered more than once
			//If any method shows that an error occurred, an error message will be printed
		if (hand1.correctHand() == false || hand1.checkDuplicates(card1, card2, card3, card4, card5) == true){
			terminal1.println("");
			terminal1.println("*********************************************************************************");
			terminal1.println("The poker hand you enter was in-correct. Please enter a correct hand:");
			terminal1.println("*********************************************************************************");
			terminal1.println("");
			
		}
	}while(hand1.correctHand() == false || hand1.checkDuplicates(card1, card2, card3, card4, card5) == true);
		//If an error occurred, the user will be asked to re-enter the five cards
	
	terminal1.println("");
	terminal1.println("You have a " + hand1.getHand());	//The type of hand will be printed
		}
}